﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace Sublimation
{
    public class Mine :Projectile
    {
        protected float LIFE_EXPECTANCY = 50000;
        protected float life;
        public Mine(WorldProperties worldProperties, bool isFriendly, Vector2 position, Vector2 velocity, float maxSpeed, Vector2 size, float range, float damagePotential)
            : base(worldProperties, isFriendly, position, velocity, maxSpeed, size, range, damagePotential)
        {
        }

        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {   
            base.Update(gameTime);
            //limited life expectancy for mine for performance issue
            //will also save african children when the war is over
            life += gameTime.ElapsedGameTime.Milliseconds;
            if (life>LIFE_EXPECTANCY)
            {
                Kill();
            }
        }

    
        protected override void LoadContent()
        {
            base.LoadContent();
            Sprite = Game.Content.Load<Texture2D>("Sprites/bullet_mine");
            Scale = 1.0f;
        }


        protected override void ExplosionAnimation(GameObject target)
        {
            new Animation(worldProperties, this, 0.4f, 5, 20, "Sprites\\bullet_hit_enemy");
        }

        public override void CheckCollisions(GameTime gameTime)
        {
            base.CheckCollisions(gameTime);

            //TODO: physical objects

            //limited range
            if (Vector2.Distance(position, initial_position) > range)
            {
                Velocity = Vector2.Zero;
            }
        }

    }
}
